﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet"
        type="text/css" />
    <script src="../../../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../../../lib/json2.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="../../../lib/ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
    <script src="../EmployeeData.js" type="text/javascript"></script>
    <script src="../DepartmentData.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).keydown(function (event)
        {
            if (event.keyCode == 37)//左
            {
                var editor = grid.editor;
                var editParm = editor.editParm;
                var cell = grid.getCellObj(editParm.record, editParm.column);

                grid.endEdit();

                grid._applyEditor($(cell).prev().get(0));
            }
            else if (event.keyCode == 39)//右
            {
                var editor = grid.editor;
                var editParm = editor.editParm;
                var cell = grid.getCellObj(editParm.record, editParm.column);

                grid.endEdit();

                grid._applyEditor($(cell).next().get(0));
            }
            else if (event.keyCode == 38) //上
            {
                var editor = grid.editor;
                var editParm = editor.editParm;
                var row = grid.getRowObj(editParm.record);
                var targetRow = $(row).prev().get(0);

                grid.endEdit();
                var targetCell = grid.getCellObj(targetRow, editParm.column);
                grid._applyEditor(targetCell);
            }
            else if (event.keyCode == 40) //上
            {
                var editor = grid.editor;
                var editParm = editor.editParm;
                var row = grid.getRowObj(editParm.record);
                var targetRow = $(row).next().get(0);

                grid.endEdit();
                var targetCell = grid.getCellObj(targetRow, editParm.column);
                grid._applyEditor(targetCell);

            }
        }); 


        var DepartmentList = DepartmentData.Rows;
        $(f_initGrid);
        function f_initGrid()
        {
          window.grid = 
           $("#maingrid").ligerGrid({
               columns: [
                { display: '主键', name: 'ID', width: 50, editor: { type: 'text'} },
                { display: '名字', name: 'RealName', width: 90, editor: { type: 'text'} },
                { display: '地址', name: 'Address', editor: { type: 'text' }, align: 'left', width: 300 }
                ], 
               enabledEdit: true, isScroll: false,
               data: EmployeeData,
               width: '100%'
           });
        } 
    </script>
</head>
<body style="padding: 10px">
    <div id="maingrid" style="margin-top: 20px">
    </div>
    <div style="display: none;">
        <!-- g data total ttt -->
    </div>
</body>
</html>
